package com.example.demo.commons.result.common.entity;



import com.example.demo.commons.result.able.EnumInterface;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

@Data
@NoArgsConstructor
public class KeyValue<k, v> {

    private k key;

    private v value;

    public KeyValue(k key, v value) {
        if (Objects.isNull(key)) {
            throw new IllegalArgumentException("Key must not be null");
        }
        this.key = key;
        this.value = value;
    }

    public static KeyValue of(EnumInterface enumInterface) {
        return new KeyValue(enumInterface.getCode(), enumInterface.getDesc());
    }
}